package com.xybbs.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import com.xybbs.entity.Replies;

public interface RepliesMapper {
	@Insert("insert into reply(user_id,tip_id,reply_content,reply_publishTime) values(#{userId},#{tipId},#{replyContent},#{replyPublishTime})")
	void insert(Replies reply);
	
	@Select("select * from reply")
//	@Results(id = "replyMap",value = {
//		@Result(column = "reply_id",property = "replyId"),
//		@Result(column = "user_id",property = "userId"),
//		@Result(column = "tip_id",property = "tipId"),
//		@Result(column = "reply_content",property = "replyContent"),
//		@Result(column = "reply_publishTime",property = "replyPublishTime"),
//		@Result(column = "reply_status",property = "replyStatus"),
//	})
	List<Replies> selectAll();
	
	@Select("select * from reply where tip_id = #{tipId}")
//	@Results(value = {
//			@Result(column = "reply_id",property = "replyId"),
//			@Result(column = "user_id",property = "userId"),
//			@Result(column = "tip_id",property = "tipId"),
//			@Result(column = "reply_content",property = "replyContent"),
//			@Result(column = "reply_publishTime",property = "replyPublishTime"),
//			@Result(column = "reply_status",property = "replyStatus"),
//			@Result(column = "user_id" ,property = "user",
//			one = @One(select = "com.xybbs.mapper.UsersMapper.selectUserById",fetchType = FetchType.LAZY))
//		})
	List<Replies> selectAllByTipIdWithUser(String tipId);

	@Delete("delete from reply where reply_Id = #{replyId}")
	void delReplyById(String replyId);

}
